<template>
</template>
<script>
const {ElLoading,ElMessage } = ElementPlus
import {socialLogin} from '../../http/auth.js'

export default {
  name: "login",
    setup() {
      const loading = ElLoading.service({
        lock: true,
        text: 'Loading',
        background: 'rgba(0, 0, 0, 0.7)',
      })
      const data= ref({})

      onMounted(()=>{

        const params = queryStringToObject(window.location.search.substring(1));
        socialLogin(params).then(res=>{
          loading.close()
          if(res.data.code===200){
            router.push("/home")
          }else{
            ElMessage.error(res.data.msg)
            //router.push("/login")
          }
        })
      })



      function queryStringToObject(queryString) {
        const params = {};
        if (!queryString) return params;
        const pairs = queryString.split('&');
        for (let pair of pairs) {
          const [key, value] = pair.split('=');
          params[decodeURIComponent(key)] = decodeURIComponent(value); // 解码key和value，以防它们包含特殊字符如空格或加号等。
        }
        return params;
      }
    }
}
</script>



<style scoped>

</style>